<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>xhrio.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
  </script>

  <script src="static/js/doc.js">
  </script>

  <meta charset="utf8">
</head>

<body onload="prettyPrint()">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="closure_goog_testing_net_xhrio.js.html">xhrio.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line2"></a>// you may not use this file except in compliance with the License.
<a name="line3"></a>// You may obtain a copy of the License at
<a name="line4"></a>//
<a name="line5"></a>//     http://www.apache.org/licenses/LICENSE-2.0
<a name="line6"></a>//
<a name="line7"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line8"></a>// distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
<a name="line9"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line10"></a>// See the License for the specific language governing permissions and
<a name="line11"></a>// limitations under the License.
<a name="line12"></a>
<a name="line13"></a>// Copyright 2007 Google Inc. All Rights Reserved.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview Mock of XhrIo for unit testing.
<a name="line17"></a> */
<a name="line18"></a>
<a name="line19"></a>goog.provide(&#39;goog.testing.net.XhrIo&#39;);
<a name="line20"></a>
<a name="line21"></a>goog.require(&#39;goog.array&#39;);
<a name="line22"></a>goog.require(&#39;goog.dom.xml&#39;);
<a name="line23"></a>goog.require(&#39;goog.events&#39;);
<a name="line24"></a>goog.require(&#39;goog.events.EventTarget&#39;);
<a name="line25"></a>goog.require(&#39;goog.json&#39;);
<a name="line26"></a>goog.require(&#39;goog.net.ErrorCode&#39;);
<a name="line27"></a>goog.require(&#39;goog.net.EventType&#39;);
<a name="line28"></a>goog.require(&#39;goog.net.XmlHttp&#39;);
<a name="line29"></a>
<a name="line30"></a>
<a name="line31"></a>
<a name="line32"></a>/**
<a name="line33"></a> * Mock implementation of goog.net.XhrIo. This doesn&#39;t provide a mock
<a name="line34"></a> * implementation for all cases, but it&#39;s not too hard to add them as needed.
<a name="line35"></a> * @param {goog.testing.TestQueue} opt_testQueue Test queue for inserting test
<a name="line36"></a> *     events.
<a name="line37"></a> * @constructor
<a name="line38"></a> * @extends {goog.events.EventTarget}
<a name="line39"></a> */
<a name="line40"></a>goog.testing.net.XhrIo = function(opt_testQueue) {
<a name="line41"></a>  goog.events.EventTarget.call(this);
<a name="line42"></a>
<a name="line43"></a>  /**
<a name="line44"></a>   * Queue of events write to.
<a name="line45"></a>   * @type {goog.testing.TestQueue?}
<a name="line46"></a>   * @private
<a name="line47"></a>   */
<a name="line48"></a>  this.testQueue_ = opt_testQueue || null;
<a name="line49"></a>};
<a name="line50"></a>goog.inherits(goog.testing.net.XhrIo, goog.events.EventTarget);
<a name="line51"></a>
<a name="line52"></a>
<a name="line53"></a>/**
<a name="line54"></a> * All non-disposed instances of goog.testing.net.XhrIo created
<a name="line55"></a> * by {@link goog.testing.net.XhrIo.send} are in this Array.
<a name="line56"></a> * @see goog.testing.net.XhrIo.cleanupAllPendingStaticSends
<a name="line57"></a> * @type {Array.&lt;goog.testing.net.XhrIo&gt;}
<a name="line58"></a> * @private
<a name="line59"></a> */
<a name="line60"></a>goog.testing.net.XhrIo.sendInstances_ = [];
<a name="line61"></a>
<a name="line62"></a>
<a name="line63"></a>/**
<a name="line64"></a> * Returns an Array containing all non-disposed instances of
<a name="line65"></a> * goog.testing.net.XhrIo created by {@link goog.testing.net.XhrIo.send}.
<a name="line66"></a> * @return {Array} Array of goog.testing.net.XhrIo instances.
<a name="line67"></a> */
<a name="line68"></a>goog.testing.net.XhrIo.getSendInstances = function() {
<a name="line69"></a>  return goog.testing.net.XhrIo.sendInstances_;
<a name="line70"></a>};
<a name="line71"></a>
<a name="line72"></a>
<a name="line73"></a>/**
<a name="line74"></a> * Simulates the static XhrIo send method.
<a name="line75"></a> * @param {string} url Uri to make request to.
<a name="line76"></a> * @param {Function} opt_callback Callback function for when request is
<a name="line77"></a> *     complete.
<a name="line78"></a> * @param {string} opt_method Send method, default: GET.
<a name="line79"></a> * @param {string} opt_content Post data.
<a name="line80"></a> * @param {Object|goog.structs.Map} opt_headers Map of headers to add to the
<a name="line81"></a> *     request.
<a name="line82"></a> * @param {number} opt_timeoutInterval Number of milliseconds after which an
<a name="line83"></a> *     incomplete request will be aborted; 0 means no timeout is set.
<a name="line84"></a> */
<a name="line85"></a>goog.testing.net.XhrIo.send = function(url, opt_callback, opt_method,
<a name="line86"></a>                                       opt_content, opt_headers,
<a name="line87"></a>                                       opt_timeoutInterval) {
<a name="line88"></a>  var x = new goog.testing.net.XhrIo();
<a name="line89"></a>  goog.testing.net.XhrIo.sendInstances_.push(x);
<a name="line90"></a>  if (opt_callback) {
<a name="line91"></a>    goog.events.listen(x, goog.net.EventType.COMPLETE, opt_callback);
<a name="line92"></a>  }
<a name="line93"></a>  goog.events.listen(x,
<a name="line94"></a>                     goog.net.EventType.READY,
<a name="line95"></a>                     goog.partial(goog.testing.net.XhrIo.cleanupSend_, x));
<a name="line96"></a>  if (opt_timeoutInterval) {
<a name="line97"></a>    x.setTimeoutInterval(opt_timeoutInterval);
<a name="line98"></a>  }
<a name="line99"></a>  x.send(url, opt_method, opt_content, opt_headers);
<a name="line100"></a>};
<a name="line101"></a>
<a name="line102"></a>
<a name="line103"></a>
<a name="line104"></a>/**
<a name="line105"></a> * Disposes of the specified goog.testing.net.XhrIo created by
<a name="line106"></a> * {@link goog.testing.net.XhrIo.send} and removes it from
<a name="line107"></a> * {@link goog.testing.net.XhrIo.pendingStaticSendInstances_}.
<a name="line108"></a> * @param {goog.testing.net.XhrIo} XhrIo An XhrIo created by
<a name="line109"></a> *     {@link goog.testing.net.XhrIo.send}.
<a name="line110"></a> * @private
<a name="line111"></a> */
<a name="line112"></a>goog.testing.net.XhrIo.cleanupSend_ = function(XhrIo) {
<a name="line113"></a>  XhrIo.dispose();
<a name="line114"></a>  goog.array.remove(goog.testing.net.XhrIo.sendInstances_, XhrIo);
<a name="line115"></a>};
<a name="line116"></a>
<a name="line117"></a>
<a name="line118"></a>/**
<a name="line119"></a> * Stores the simulated response headers for the requests which are sent through
<a name="line120"></a> * this XhrIo.
<a name="line121"></a> * @type {Object}
<a name="line122"></a> * @private
<a name="line123"></a> */
<a name="line124"></a>goog.testing.net.XhrIo.prototype.responseHeaders_;
<a name="line125"></a>
<a name="line126"></a>
<a name="line127"></a>/**
<a name="line128"></a> * Whether MockXhrIo is active.
<a name="line129"></a> * @type {boolean}
<a name="line130"></a> * @private
<a name="line131"></a> */
<a name="line132"></a>goog.testing.net.XhrIo.prototype.active_ = false;
<a name="line133"></a>
<a name="line134"></a>
<a name="line135"></a>/**
<a name="line136"></a> * Last URI that was requested.
<a name="line137"></a> * @type {string}
<a name="line138"></a> * @private
<a name="line139"></a> */
<a name="line140"></a>goog.testing.net.XhrIo.prototype.lastUri_ = &#39;&#39;;
<a name="line141"></a>
<a name="line142"></a>
<a name="line143"></a>/**
<a name="line144"></a> * Last error code.
<a name="line145"></a> * @type {goog.net.ErrorCode}
<a name="line146"></a> * @private
<a name="line147"></a> */
<a name="line148"></a>goog.testing.net.XhrIo.prototype.lastErrorCode_ =
<a name="line149"></a>    goog.net.ErrorCode.NO_ERROR;
<a name="line150"></a>
<a name="line151"></a>
<a name="line152"></a>/**
<a name="line153"></a> * Last error message.
<a name="line154"></a> * @type {string}
<a name="line155"></a> * @private
<a name="line156"></a> */
<a name="line157"></a>goog.testing.net.XhrIo.prototype.lastError_ = &#39;&#39;;
<a name="line158"></a>
<a name="line159"></a>
<a name="line160"></a>/**
<a name="line161"></a> * Mock ready state.
<a name="line162"></a> * @type {number}
<a name="line163"></a> * @private
<a name="line164"></a> */
<a name="line165"></a>goog.testing.net.XhrIo.prototype.readyState_ =
<a name="line166"></a>    goog.net.XmlHttp.ReadyState.UNINITIALIZED;
<a name="line167"></a>
<a name="line168"></a>
<a name="line169"></a>/**
<a name="line170"></a> * Number of milliseconds after which an incomplete request will be aborted and
<a name="line171"></a> * a {@link goog.net.EventType.TIMEOUT} event raised; 0 means no timeout is set.
<a name="line172"></a> * @type {number}
<a name="line173"></a> * @private
<a name="line174"></a> */
<a name="line175"></a>goog.testing.net.XhrIo.prototype.timeoutInterval_ = 0;
<a name="line176"></a>
<a name="line177"></a>
<a name="line178"></a>/**
<a name="line179"></a> * Window timeout ID used to cancel the timeout event handler if the request
<a name="line180"></a> * completes successfully.
<a name="line181"></a> * @type {Object?}
<a name="line182"></a> * @private
<a name="line183"></a> */
<a name="line184"></a>goog.testing.net.XhrIo.prototype.timeoutId_ = null;
<a name="line185"></a>
<a name="line186"></a>
<a name="line187"></a>/**
<a name="line188"></a> * Returns the number of milliseconds after which an incomplete request will be
<a name="line189"></a> * aborted, or 0 if no timeout is set.
<a name="line190"></a> * @return {number} Timeout interval in milliseconds.
<a name="line191"></a> */
<a name="line192"></a>goog.testing.net.XhrIo.prototype.getTimeoutInterval = function() {
<a name="line193"></a>  return this.timeoutInterval_;
<a name="line194"></a>};
<a name="line195"></a>
<a name="line196"></a>
<a name="line197"></a>/**
<a name="line198"></a> * Sets the number of milliseconds after which an incomplete request will be
<a name="line199"></a> * aborted and a {@link goog.net.EventType.TIMEOUT} event raised; 0 means no
<a name="line200"></a> * timeout is set.
<a name="line201"></a> * @param {number} ms Timeout interval in milliseconds; 0 means none.
<a name="line202"></a> */
<a name="line203"></a>goog.testing.net.XhrIo.prototype.setTimeoutInterval = function(ms) {
<a name="line204"></a>  this.timeoutInterval_ = Math.max(0, ms);
<a name="line205"></a>};
<a name="line206"></a>
<a name="line207"></a>
<a name="line208"></a>/**
<a name="line209"></a> * Causes timeout events to be fired.
<a name="line210"></a> */
<a name="line211"></a>goog.testing.net.XhrIo.prototype.simulateTimeout = function() {
<a name="line212"></a>  this.lastErrorCode_ = goog.net.ErrorCode.TIMEOUT;
<a name="line213"></a>  this.dispatchEvent(goog.net.EventType.TIMEOUT);
<a name="line214"></a>  this.abort(goog.net.ErrorCode.TIMEOUT);
<a name="line215"></a>};
<a name="line216"></a>
<a name="line217"></a>
<a name="line218"></a>/**
<a name="line219"></a> * Abort the current XMLHttpRequest
<a name="line220"></a> * @param {goog.net.ErrorCode} opt_failureCode Optional error code to use -
<a name="line221"></a> *     defaults to ABORT.
<a name="line222"></a> */
<a name="line223"></a>goog.testing.net.XhrIo.prototype.abort = function(opt_failureCode) {
<a name="line224"></a>  if (this.active_) {
<a name="line225"></a>    this.active_ = false;
<a name="line226"></a>    this.lastErrorCode_ = opt_failureCode || goog.net.ErrorCode.ABORT;
<a name="line227"></a>    this.dispatchEvent(goog.net.EventType.COMPLETE);
<a name="line228"></a>    this.dispatchEvent(goog.net.EventType.ABORT);
<a name="line229"></a>  }
<a name="line230"></a>};
<a name="line231"></a>
<a name="line232"></a>
<a name="line233"></a>/**
<a name="line234"></a> * Simulates the XhrIo send.
<a name="line235"></a> * @param {string} url Uri to make request too.
<a name="line236"></a> * @param {string} opt_method Send method, default: GET.
<a name="line237"></a> * @param {string} opt_content Post data.
<a name="line238"></a> * @param {Object|goog.structs.Map} opt_headers Map of headers to add to the
<a name="line239"></a> *     request.
<a name="line240"></a> */
<a name="line241"></a>goog.testing.net.XhrIo.prototype.send = function(url, opt_method, opt_content,
<a name="line242"></a>                                                 opt_headers) {
<a name="line243"></a>  if (this.active_) {
<a name="line244"></a>    throw Error(&#39;[goog.net.XhrIo] Object is active with another request&#39;);
<a name="line245"></a>  }
<a name="line246"></a>
<a name="line247"></a>  this.lastUri_ = url;
<a name="line248"></a>
<a name="line249"></a>  if (this.testQueue_) {
<a name="line250"></a>    this.testQueue_.enqueue([&#39;s&#39;, url, opt_method, opt_content, opt_headers]);
<a name="line251"></a>  }
<a name="line252"></a>  this.readyState_ = goog.net.XmlHttp.ReadyState.UNINITIALIZED;
<a name="line253"></a>  this.simulateReadyStateChange(goog.net.XmlHttp.ReadyState.LOADING);
<a name="line254"></a>  this.active_ = true;
<a name="line255"></a>};
<a name="line256"></a>
<a name="line257"></a>
<a name="line258"></a>/**
<a name="line259"></a> * Simulates changing to the new ready state.
<a name="line260"></a> * @param {number} readyState Ready state to change to.
<a name="line261"></a> */
<a name="line262"></a>goog.testing.net.XhrIo.prototype.simulateReadyStateChange =
<a name="line263"></a>    function(readyState) {
<a name="line264"></a>  if (readyState &lt; this.readyState_) {
<a name="line265"></a>    throw Error(&#39;Readystate cannot go backwards&#39;);
<a name="line266"></a>  }
<a name="line267"></a>
<a name="line268"></a>  while (this.readyState_ &lt; readyState) {
<a name="line269"></a>    this.readyState_++;
<a name="line270"></a>    this.dispatchEvent(goog.net.EventType.READY_STATE_CHANGE);
<a name="line271"></a>
<a name="line272"></a>    if (this.readyState_ == goog.net.XmlHttp.ReadyState.COMPLETE) {
<a name="line273"></a>      this.active_ = false;
<a name="line274"></a>      this.dispatchEvent(goog.net.EventType.COMPLETE);
<a name="line275"></a>    }
<a name="line276"></a>  }
<a name="line277"></a>};
<a name="line278"></a>
<a name="line279"></a>
<a name="line280"></a>/**
<a name="line281"></a> * Simulates receiving a response.
<a name="line282"></a> * @param {number} statusCode Simulated status code.
<a name="line283"></a> * @param {string|Document} response Simulated response.
<a name="line284"></a> * @param {Object} opt_headers Simulated response headers.
<a name="line285"></a> */
<a name="line286"></a>goog.testing.net.XhrIo.prototype.simulateResponse = function(statusCode,
<a name="line287"></a>    response, opt_headers) {
<a name="line288"></a>  this.statusCode_ = statusCode;
<a name="line289"></a>  this.response_ = response;
<a name="line290"></a>  this.responseHeaders_ = opt_headers || {};
<a name="line291"></a>  this.simulateReadyStateChange(goog.net.XmlHttp.ReadyState.COMPLETE);
<a name="line292"></a>
<a name="line293"></a>  if (this.isSuccess()) {
<a name="line294"></a>    this.dispatchEvent(goog.net.EventType.SUCCESS);
<a name="line295"></a>  } else {
<a name="line296"></a>    this.lastErrorCode_ = goog.net.ErrorCode.HTTP_ERROR;
<a name="line297"></a>    this.lastError_ = this.getStatusText() + &#39; [&#39; + this.getStatus() + &#39;]&#39;;
<a name="line298"></a>    this.dispatchEvent(goog.net.EventType.ERROR);
<a name="line299"></a>  }
<a name="line300"></a>};
<a name="line301"></a>
<a name="line302"></a>
<a name="line303"></a>/**
<a name="line304"></a> * Simulates the Xhr is ready for the next request.
<a name="line305"></a> */
<a name="line306"></a>goog.testing.net.XhrIo.prototype.simulateReady = function() {
<a name="line307"></a>  this.dispatchEvent(goog.net.EventType.READY);
<a name="line308"></a>};
<a name="line309"></a>
<a name="line310"></a>
<a name="line311"></a>/**
<a name="line312"></a> * @return {boolean} Whether there is an active request.
<a name="line313"></a> */
<a name="line314"></a>goog.testing.net.XhrIo.prototype.isActive = function() {
<a name="line315"></a>  return this.active_;
<a name="line316"></a>};
<a name="line317"></a>
<a name="line318"></a>
<a name="line319"></a>/**
<a name="line320"></a> * Has the request completed.
<a name="line321"></a> * @return {boolean} Whether the request has completed.
<a name="line322"></a> */
<a name="line323"></a>goog.testing.net.XhrIo.prototype.isComplete = function() {
<a name="line324"></a>  return this.readyState_ == goog.net.XmlHttp.ReadyState.COMPLETE;
<a name="line325"></a>};
<a name="line326"></a>
<a name="line327"></a>
<a name="line328"></a>/**
<a name="line329"></a> * Has the request compeleted with a success.
<a name="line330"></a> * @return {boolean} Whether the request compeleted successfully.
<a name="line331"></a> */
<a name="line332"></a>goog.testing.net.XhrIo.prototype.isSuccess = function() {
<a name="line333"></a>  switch (this.statusCode_) {
<a name="line334"></a>    case 0:         // Used for local XHR requests
<a name="line335"></a>    case 200:       // HTTP Success
<a name="line336"></a>    case 204:       // HTTP Success - no content
<a name="line337"></a>    case 304:       // HTTP Cache
<a name="line338"></a>      return true;
<a name="line339"></a>
<a name="line340"></a>    default:
<a name="line341"></a>      return false;
<a name="line342"></a>  }
<a name="line343"></a>};
<a name="line344"></a>
<a name="line345"></a>
<a name="line346"></a>/**
<a name="line347"></a> * Returns the readystate.
<a name="line348"></a> * @return {number} goog.net.XmlHttp.ReadyState.*.
<a name="line349"></a> */
<a name="line350"></a>goog.testing.net.XhrIo.prototype.getReadyState = function() {
<a name="line351"></a>  return this.readyState_;
<a name="line352"></a>};
<a name="line353"></a>
<a name="line354"></a>
<a name="line355"></a>/**
<a name="line356"></a> * Get the status from the Xhr object.  Will only return correct result when
<a name="line357"></a> * called from the context of a callback.
<a name="line358"></a> * @return {number} Http status.
<a name="line359"></a> */
<a name="line360"></a>goog.testing.net.XhrIo.prototype.getStatus = function() {
<a name="line361"></a>  return this.statusCode_;
<a name="line362"></a>};
<a name="line363"></a>
<a name="line364"></a>
<a name="line365"></a>/**
<a name="line366"></a> * Get the status text from the Xhr object.  Will only return correct result
<a name="line367"></a> * when called from the context of a callback.
<a name="line368"></a> * @return {string} Status text.
<a name="line369"></a> */
<a name="line370"></a>goog.testing.net.XhrIo.prototype.getStatusText = function() {
<a name="line371"></a>  return &#39;&#39;;
<a name="line372"></a>};
<a name="line373"></a>
<a name="line374"></a>
<a name="line375"></a>/**
<a name="line376"></a> * Gets the last error message.
<a name="line377"></a> * @return {goog.net.ErrorCode} Last error code.
<a name="line378"></a> */
<a name="line379"></a>goog.testing.net.XhrIo.prototype.getLastErrorCode = function() {
<a name="line380"></a>  return this.lastErrorCode_;
<a name="line381"></a>};
<a name="line382"></a>
<a name="line383"></a>
<a name="line384"></a>/**
<a name="line385"></a> * Gets the last error message.
<a name="line386"></a> * @return {string} Last error message.
<a name="line387"></a> */
<a name="line388"></a>goog.testing.net.XhrIo.prototype.getLastError = function() {
<a name="line389"></a>  return this.lastError_;
<a name="line390"></a>};
<a name="line391"></a>
<a name="line392"></a>
<a name="line393"></a>/**
<a name="line394"></a> * Gets the last URI that was requested.
<a name="line395"></a> * @return {string} Last URI.
<a name="line396"></a> */
<a name="line397"></a>goog.testing.net.XhrIo.prototype.getLastUri = function() {
<a name="line398"></a>  return this.lastUri_;
<a name="line399"></a>};
<a name="line400"></a>
<a name="line401"></a>
<a name="line402"></a>/**
<a name="line403"></a> * Gets the response text from the Xhr object.  Will only return correct result
<a name="line404"></a> * when called from the context of a callback.
<a name="line405"></a> * @return {string} Result from the server.
<a name="line406"></a> */
<a name="line407"></a>goog.testing.net.XhrIo.prototype.getResponseText = function() {
<a name="line408"></a>  return goog.isString(this.response_) ? this.response_ :
<a name="line409"></a>         goog.dom.xml.serialize(this.response_);
<a name="line410"></a>};
<a name="line411"></a>
<a name="line412"></a>
<a name="line413"></a>/**
<a name="line414"></a> * Gets the response and evaluates it as JSON from the Xhr object.  Will only
<a name="line415"></a> * return correct result when called from the context of a callback.
<a name="line416"></a> * @return {Object} JavaScript object.
<a name="line417"></a> */
<a name="line418"></a>goog.testing.net.XhrIo.prototype.getResponseJson = function() {
<a name="line419"></a>  return goog.json.parse(this.getResponseText());
<a name="line420"></a>};
<a name="line421"></a>
<a name="line422"></a>
<a name="line423"></a>/**
<a name="line424"></a> * Gets the response XML from the Xhr object.  Will only return correct result
<a name="line425"></a> * when called from the context of a callback.
<a name="line426"></a> * @return {Document?} Result from the server if it was XML.
<a name="line427"></a> */
<a name="line428"></a>goog.testing.net.XhrIo.prototype.getResponseXml = function() {
<a name="line429"></a>  // NOTE: I haven&#39;t found out how to check in Internet Explorer
<a name="line430"></a>  // whether the response is XML document, so I do it the other way around.
<a name="line431"></a>  return goog.isString(this.response_) ? null : this.response_;
<a name="line432"></a>};
<a name="line433"></a>
<a name="line434"></a>
<a name="line435"></a>/**
<a name="line436"></a> * Get the value of the response-header with the given name from the Xhr object
<a name="line437"></a> * Will only return correct result when called from the context of a callback
<a name="line438"></a> * and the request has completed
<a name="line439"></a> * @param {string} key The name of the response-header to retrieve.
<a name="line440"></a> * @return {string|undefined} The value of the response-header named key.
<a name="line441"></a> */
<a name="line442"></a>goog.testing.net.XhrIo.prototype.getResponseHeader = function(key) {
<a name="line443"></a>  return this.isComplete() ? this.responseHeaders_[key] : undefined;
<a name="line444"></a>};
</pre>


</body>
</html>
